/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.junit.platform.commons.util.StringUtils;

import java.util.stream.Stream;

import static org.junit.jupiter.params.provider.Arguments.arguments;

/**
 * <p>Project: app2022 - T2
 * <p>Powered by webrx On 2022-02-08 16:12:14
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */

@Slf4j
@DisplayName("单元测试，测试有参数的方法和返回值方法")

public class T2 {
    static Stream<Arguments> ss() {
        return Stream.of(
                arguments(7, 9)
        );
    }

    @ParameterizedTest
    @CsvSource("hello,world,java17")
    @DisplayName("有参数")
    void pf(String str, String aa, String jv) {
        System.out.println(str);
        System.out.println(aa);
        System.out.println(jv);
    }

    @ParameterizedTest
    @CsvSource("10,50")
    @DisplayName("有参数")
    void sum(int a, int b) {
        System.out.println(a);
        System.out.println(b);
        System.out.println(a + b);
    }

    @Test
    void sum() {
        Assertions.assertEquals(8, 2 + 6);
    }

    @ParameterizedTest
    //@ValueSource(ints = {3, 6})
    @MethodSource("ss")
    @DisplayName("参数化测试2")
    public void t2(int a, int b) {
        System.out.println(a + b);
        Assertions.assertEquals(a + b, 16);
    }

    @ParameterizedTest
    @ValueSource(strings = {"racecar", "radar", "able was I ere I saw elba"})
    void palindromes(String sss) {
        System.out.println(sss);
        Assertions.assertTrue(StringUtils.isNotBlank(sss));
    }

    @Test
    @DisplayName("测试T2.ta()方法")
    void ta() {
        log.info("ta()");
    }
}
